package com.shop.interceptors;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor  extends AbstractInterceptor{

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		//1.获取session
		ActionContext ctx = invocation.getInvocationContext();
		String loginname = (String) ctx.getSession().get("loginname");
		if(loginname==null){
			ActionContext.getContext().put("msg","请登录再执行转账业务...");
			return Action.LOGIN;
		}else{
			//2.继续执行后续流程
			return invocation.invoke();
		}
		
	}

}
